<template>
	<view class="warp">
		<view class=" source_tab">
			<view @click="changtab(index)" :class="currentIndex==index ? 'selected' :''" v-for="(item,index) in list" :key="index">{{item.value}}</view>
		</view>
		<view class="sourceList" v-for="(item,indx) in materiallist" :key="indx" >
			<view class=" flex">
				<view class="" >
					<image v-if="item.fileType=='1'" class="source_image" :src="item.fileUrl" mode="widthFix" @click="showImage(item)"></image>
					<video @play="tovideo(item)" id="video" ref="myVideo" poster=""  style="width: 220rpx;height: 220rpx;margin-right: 30rpx;" v-if="item.fileType=='2'" :src="item.fileUrl"></video>
					 
				</view>
			<view class="sourceList_right" >
				   <view style="word-wrap:anywhere"  @click="toinfo(item)" class="sourceList_right_title">{{item.fileName}}</view>
				   <!-- <view style="color: rgb(101,101,101);">{{item.createTime}}发布</view>
				   <view class="flex">
					   <view style="color: rgb(0,160,233);">{{item.fodderCategoryName}}</view>
					   <uni-icons type="forward" color="#00a0e9" size="12"></uni-icons>
				   </view>
				   <view class="flex">
					   <view style="color: rgb(238,33,45);">已开启0元购活动</view>
					   <uni-icons type="forward" color="#ee212d" size="12"></uni-icons>
				   </view>
				   <view class="flex">
					   <view>{{item.forwardCount}}人参与推广</view>
					   <uni-icons type="forward" size="12"></uni-icons>
				   </view> -->
			   </view>
			</view>
			<!-- <view class="flex2">
				<view style="color: rgb(195,195,195);">{{item.viewCount}}浏览</view>
				
				<view class="flex" v-if="item.storeId=='00001'" >
					<view class="source_more flex3" @click="morefn(item)">更多</view>
					<view class="source_all flex3" @click="copysource(item)">
						借鉴素材
					</view>
				</view>
				<view class="flex" v-else>
					<view class="source_more flex3" @click="morefn(item)">更多</view>
					<view class="source_all flex3" @click="open(item,1)">全网推</view>
				</view>
			</view> -->
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:[{value:'视频素材'},{value:'图片素材'}],
				currentIndex:0,
				materiallist:[
					 
				],
				queryform:{
					current: 1,
					pageSize: 10,
					// storeId:310017,
					fileType:2
				},
				total:0,
			};
		},
		onLoad() {
			this.getlist()
		},
		// 下拉
		onPullDownRefresh() {
			// 刷新位置
			this.getlist()
				var that=this
				// uni.startPullDownRefresh({
				// 	success() {
						
				// 	},
				// 	fail(){
				// 		that.$refs.uToast.show({
				// 			type:'error',
				// 			title:'刷新失败'
				// 		})
				// 	}
				// })
				setTimeout(function(){
					uni.stopPullDownRefresh()
				},1000)
		},
		onReachBottom(){
			if(this.queryform.current*this.queryform.pageSize>=this.total){
				uni.showToast({
					title:'没有了',
					icon:'none'
				})
			}else{
				this.queryform.current++
				this.$request({
					url:'v3/system/front/material/file/list',
					method:'GET',
					data:this.queryform
				}).then(res=>{
					this.materiallist.push(...res.data.list)
				    this.total=res.data.pagination.total
					 
				})
			}
		},
		methods:{
			// 获取素材
			getlist(){
				this.$request({
					url:'v3/system/front/material/file/list',
					method:'GET',
					data:this.queryform
				}).then(res=>{
					this.materiallist=res.data.list
					 this.total=res.data.pagination.total
				})
			},
			// tab切换
			changtab(val){
				this.currentIndex=val
				if(val==0){
					this.queryform.fileType=2
					this.getlist()
				}else{
					this.queryform.fileType=1
					this.getlist()
				}
			},
			// 获取数据
			toinfo(val){
			 console.log(val,'转发');
			    uni.navigateTo({
			    	url:"/extra/svideo/svideoRelease?id="+val.bindId
			    })
			}
		}
	}
</script>

<style lang="scss">
.warp{
	.source_tab{
		width: 100%;
		margin: 10rpx 0 4rpx 0;
		background-color: #fff;
		line-height: 88rpx;
		padding: 0 20%;
		display: flex;
		justify-content: space-between;
	}
	.selected{
		border-bottom: 6rpx solid rgb(255,0,0);
	}
	.sourceList{
		margin: 20rpx 30rpx;
		background-color: #fff;
		padding: 30rpx;
		border-radius: 15rpx;
		box-shadow: 0rpx 0rpx 15rpx #cecece;
	}
	.source_image{
		width: 220rpx;
		height: 180rpx;
		margin-right: 31rpx;
		
	}
	.sourceList_right{
		font-size: 24rpx;
		line-height: 40rpx;
		 color: rgb(40,40,40);
		font-family: "PingFang-SC-Regular";
	}
	
	.sourceList_right_title{
		 color: rgb(40,40,40);
		 font-family: "PingFang-SC-Medium";
		 font-size: 28rpx;
		 font-weight: 700;
	}
	
	.source_more{
		width: 92rpx;
		height: 44rpx;
		border-radius: 15rpx;
		border: 2rpx solid #eee;
		font-size: 24rpx;
	}
	.source_all{
		width: 120rpx;
		height: 44rpx;
		border: 2rpx solid #eee;
		font-size: 24rpx;
		border-radius: 15rpx;
		margin-left: 20rpx;
		color: #fff;
		background-image: linear-gradient(270deg,rgb(255,77,87),rgb(238,33,45));
	}
}
</style>
